<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- qsgnode.cpp -->
  <title>QSGGeometryNode 类 | Qt Quick 5.12.3</title>
  <link rel="stylesheet" type="text/css" href="style/offline-simple.css" />
  <script type="text/javascript">
    document.getElementsByTagName("link").item(0).setAttribute("href", "style/offline.css");
    // loading style sheet breaks anchors that were jumped to before
    // so force jumping to anchor again
    setTimeout(function() {
        var anchor = location.hash;
        // need to jump to different anchor first (e.g. none)
        location.hash = "#";
        setTimeout(function() {
            location.hash = anchor;
        }, 0);
    }, 0);
  </script>
</head>
<body>
<div class="header" id="qtdocheader">
  <div class="main">
    <div class="main-rounded">
      <div class="navigationbar">
        <table><tr>
<td ><a href="../qtdoc/index.html">Qt 5.12</a></td><td ><a href="qtquick-index.html">Qt Quick 模块</a></td><td ><a href="qtquick-module.html">C++ 类</a></td><td >QSGGeometryNode</td></tr></table><table class="buildversion"><tr>
<td id="buildversion" width="100%" align="right"><a href="qtquick-index.html">Qt 5.12.3 参考指南</a></td>
        </tr></table>
      </div>
    </div>
<div class="content">
<div class="line">
<div class="content mainContent">
<div class="sidebar">
<div class="toc">
<h3><a name="toc">目录</a></h3>
<ul>
<li class="level1"><a href="#public-functions">公用函数</a></li>
<li class="level1"><a href="#details">详细信息</a></li>
</ul>
</div>
<div class="sidebar-content" id="sidebar-content"></div></div>
<h1 class="title">QSGGeometryNode 类</h1>
<!-- $$$QSGGeometryNode-brief -->
<p>The <a href="qsggeometrynode.html">QSGGeometryNode</a> class is used for all rendered content in the scene graph. <a href="#details">更多...</a></p>
<!-- @@@QSGGeometryNode -->
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign">头文件：</td><td class="memItemRight bottomAlign">   <span class="preprocessor">#include &lt;QSGGeometryNode&gt;</span>
</td></tr><tr><td class="memItemLeft rightAlign topAlign"> qmake:</td><td class="memItemRight bottomAlign"> QT += quick</td></tr><tr><td class="memItemLeft rightAlign topAlign">继承自：</td><td class="memItemRight bottomAlign"> <a href="qsgbasicgeometrynode.html">QSGBasicGeometryNode</a></td></tr><tr><td class="memItemLeft rightAlign topAlign"> 被继承：</td><td class="memItemRight bottomAlign"> <p><a href="qsgimagenode.html">QSGImageNode</a>, <a href="qsgrectanglenode.html">QSGRectangleNode</a>, <a href="qsgsimplerectnode.html" class="obsolete">QSGSimpleRectNode</a>, and <a href="qsgsimpletexturenode.html" class="obsolete">QSGSimpleTextureNode</a></p>
</td></tr></table></div><ul>
<li><a href="qsggeometrynode-members.html">所有成员的列表，包括继承成员</a></li>
</ul>
<a name="public-functions"></a>
<h2 id="public-functions">公用函数</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qsggeometrynode.html#QSGGeometryNode">QSGGeometryNode</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual </td><td class="memItemRight bottomAlign"><b><a href="qsggeometrynode.html#dtor.QSGGeometryNode">~QSGGeometryNode</a></b>() override</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QSGMaterial *</td><td class="memItemRight bottomAlign"><b><a href="qsggeometrynode.html#material">material</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QSGMaterial *</td><td class="memItemRight bottomAlign"><b><a href="qsggeometrynode.html#opaqueMaterial">opaqueMaterial</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qsggeometrynode.html#setMaterial">setMaterial</a></b>(QSGMaterial *<i>material</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qsggeometrynode.html#setOpaqueMaterial">setOpaqueMaterial</a></b>(QSGMaterial *<i>material</i>)</td></tr>
</table></div>
<ul>
<li class="fn">3 个公用函数继承自<a href="qsgbasicgeometrynode.html#public-functions">QSGBasicGeometryNode</a></li>
<li class="fn">20 个公用函数继承自<a href="qsgnode.html#public-functions">QSGNode</a></li>
</ul>
<a name="details"></a>
<!-- $$$QSGGeometryNode-description -->
<div class="descr">
<h2 id="details">详细信息</h2>
<p>The <a href="qsggeometrynode.html">QSGGeometryNode</a> class is used for all rendered content in the scene graph.</p>
<p>The <a href="qsggeometrynode.html">QSGGeometryNode</a> consists of geometry and material. The geometry defines the mesh, the vertices and their structure, to be drawn. The Material defines how the shape is filled.</p>
<p>The following is a code snippet illustrating how to create a red line using a <a href="qsggeometrynode.html">QSGGeometryNode</a>:</p>
<pre class="cpp">

  <span class="type"><a href="qsggeometry.html">QSGGeometry</a></span> <span class="operator">*</span>geometry <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qsggeometry.html">QSGGeometry</a></span>(<span class="type"><a href="qsggeometry.html">QSGGeometry</a></span><span class="operator">::</span>defaultAttributes_Point2D()<span class="operator">,</span> <span class="number">2</span>);
  geometry<span class="operator">-</span><span class="operator">&gt;</span>setDrawingMode(GL_LINES);
  geometry<span class="operator">-</span><span class="operator">&gt;</span>setLineWidth(<span class="number">3</span>);
  geometry<span class="operator">-</span><span class="operator">&gt;</span>vertexDataAsPoint2D()<span class="operator">[</span><span class="number">0</span><span class="operator">]</span><span class="operator">.</span>set(<span class="number">0</span><span class="operator">,</span> <span class="number">0</span>);
  geometry<span class="operator">-</span><span class="operator">&gt;</span>vertexDataAsPoint2D()<span class="operator">[</span><span class="number">1</span><span class="operator">]</span><span class="operator">.</span>set(width()<span class="operator">,</span> height());

  <span class="type"><a href="qsgflatcolormaterial.html">QSGFlatColorMaterial</a></span> <span class="operator">*</span>material <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qsgflatcolormaterial.html">QSGFlatColorMaterial</a></span>;
  material<span class="operator">-</span><span class="operator">&gt;</span>setColor(<span class="type"><a href="../qtgui/qcolor.html">QColor</a></span>(<span class="number">255</span><span class="operator">,</span> <span class="number">0</span><span class="operator">,</span> <span class="number">0</span>));

  <span class="type"><a href="qsggeometrynode.html#QSGGeometryNode">QSGGeometryNode</a></span> <span class="operator">*</span>node <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qsggeometrynode.html#QSGGeometryNode">QSGGeometryNode</a></span>;
  node<span class="operator">-</span><span class="operator">&gt;</span>setGeometry(geometry);
  node<span class="operator">-</span><span class="operator">&gt;</span>setFlag(<span class="type"><a href="qsgnode.html#QSGNode">QSGNode</a></span><span class="operator">::</span>OwnsGeometry);
  node<span class="operator">-</span><span class="operator">&gt;</span>setMaterial(material);
  node<span class="operator">-</span><span class="operator">&gt;</span>setFlag(<span class="type"><a href="qsgnode.html#QSGNode">QSGNode</a></span><span class="operator">::</span>OwnsMaterial);

</pre>
<p>A geometry node must have both geometry and a normal material before it is added to the scene graph. When the geometry and materials are changed after the node has been added to the scene graph, the user should also mark them as dirty using <a href="qsgnode.html#markDirty">QSGNode::markDirty</a>().</p>
<p>The geometry node supports two types of materials, the <a href="qsggeometrynode.html#opaqueMaterial">opaqueMaterial</a> and the normal material. The <a href="qsggeometrynode.html#opaqueMaterial">opaqueMaterial</a> is used when the accumulated scene graph opacity at the time of rendering is 1. The primary use case is to special case opaque rendering to avoid an extra operation in the fragment shader can have significant performance impact on embedded graphics chips. The opaque material is optional.</p>
<p><b>Note: </b>All classes with QSG prefix should be used solely on the scene graph's rendering thread. See <a href="qtquick-visualcanvas-scenegraph.html#scene-graph-and-rendering">Scene Graph and Rendering</a> for more information.</p></div>
<p><b>请参考</b> <a href="qsggeometry.html">QSGGeometry</a>，<a href="qsgmaterial.html">QSGMaterial</a> 和 <a href="qsgsimplematerial.html">QSGSimpleMaterial</a>。</p>
<!-- @@@QSGGeometryNode -->
<div class="func">
<h2>成员函数文档</h2>
<!-- $$$QSGGeometryNode[overload1]$$$QSGGeometryNode -->
<h3 class="fn" id="QSGGeometryNode"><a name="QSGGeometryNode"></a>QSGGeometryNode::<span class="name">QSGGeometryNode</span>()</h3>
<p>Creates a new geometry node without geometry and material.</p>
<!-- @@@QSGGeometryNode -->
<!-- $$$~QSGGeometryNode[overload1]$$$~QSGGeometryNode -->
<h3 class="fn" id="dtor.QSGGeometryNode"><a name="dtor.QSGGeometryNode"></a><code>[override virtual] </code>QSGGeometryNode::<span class="name">~QSGGeometryNode</span>()</h3>
<p>Deletes this geometry node.</p>
<p>The flags <a href="qsgnode.html#Flag-enum">QSGNode::OwnsMaterial</a>, <a href="qsgnode.html#Flag-enum">QSGNode::OwnsOpaqueMaterial</a> and <a href="qsgnode.html#Flag-enum">QSGNode::OwnsGeometry</a> decides whether the geometry node should also delete the materials and geometry. By default, these flags are disabled.</p>
<!-- @@@~QSGGeometryNode -->
<!-- $$$material[overload1]$$$material -->
<h3 class="fn" id="material"><a name="material"></a><span class="type"><a href="qsgmaterial.html">QSGMaterial</a></span> *QSGGeometryNode::<span class="name">material</span>() const</h3>
<p>Returns the material of the <a href="qsggeometrynode.html">QSGGeometryNode</a>.</p>
<p><b>请参考 </b><a href="qsggeometrynode.html#setMaterial">setMaterial</a>()。</p>
<!-- @@@material -->
<!-- $$$opaqueMaterial[overload1]$$$opaqueMaterial -->
<h3 class="fn" id="opaqueMaterial"><a name="opaqueMaterial"></a><span class="type"><a href="qsgmaterial.html">QSGMaterial</a></span> *QSGGeometryNode::<span class="name">opaqueMaterial</span>() const</h3>
<p>Returns the opaque material of the <a href="qsggeometrynode.html">QSGGeometryNode</a>.</p>
<p><b>请参考 </b><a href="qsggeometrynode.html#setOpaqueMaterial">setOpaqueMaterial</a>()。</p>
<!-- @@@opaqueMaterial -->
<!-- $$$setMaterial[overload1]$$$setMaterialQSGMaterial* -->
<h3 class="fn" id="setMaterial"><a name="setMaterial"></a><span class="type">void</span> QSGGeometryNode::<span class="name">setMaterial</span>(<span class="type"><a href="qsgmaterial.html">QSGMaterial</a></span> *<i>material</i>)</h3>
<p>Sets the material of this geometry node to <i>material</i>.</p>
<p>Geometry nodes must have a material before they can be added to the scene graph.</p>
<p>If the material is changed without calling setMaterial() again, the user must also mark the material as dirty using <a href="qsgnode.html#markDirty">QSGNode::markDirty</a>().</p>
<p><b>请参考 </b><a href="qsggeometrynode.html#material">material</a>()。</p>
<!-- @@@setMaterial -->
<!-- $$$setOpaqueMaterial[overload1]$$$setOpaqueMaterialQSGMaterial* -->
<h3 class="fn" id="setOpaqueMaterial"><a name="setOpaqueMaterial"></a><span class="type">void</span> QSGGeometryNode::<span class="name">setOpaqueMaterial</span>(<span class="type"><a href="qsgmaterial.html">QSGMaterial</a></span> *<i>material</i>)</h3>
<p>Sets the opaque material of this geometry to <i>material</i>.</p>
<p>The opaque material will be preferred by the renderer over the default material, as returned by the <a href="qsggeometrynode.html#material">material</a>() function, if it is not null and the geometry item has an inherited opacity of 1.</p>
<p>The opaqueness refers to scene graph opacity, the material is still allowed to set <a href="qsgmaterial.html#Flag-enum">QSGMaterial::Blending</a> to true and draw transparent pixels.</p>
<p>If the material is changed without calling setOpaqueMaterial() again, the user must also mark the opaque material as dirty using <a href="qsgnode.html#markDirty">QSGNode::markDirty</a>().</p>
<p><b>请参考 </b><a href="qsggeometrynode.html#opaqueMaterial">opaqueMaterial</a>()。</p>
<!-- @@@setOpaqueMaterial -->
</div>
        </div>
       </div>
   </div>
   </div>
</div>
<div class="footer">
   <p>
   <acronym title="Copyright">&copy;</acronym> 2019 The Qt Company Ltd.
   Documentation contributions included herein are the copyrights of
   their respective owners.<br/>    The documentation provided herein is licensed under the terms of the    <a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation    License version 1.3</a> as published by the Free Software Foundation.<br/>    Qt and respective logos are trademarks of The Qt Company Ltd.     in Finland and/or other countries worldwide. All other trademarks are property
   of their respective owners. </p>
</div>
</body>
</html>
